package net.piggy.core.session.dubbo;

import com.alibaba.fastjson.JSONObject;
import net.piggy.core.executor.Executor;
import net.piggy.core.executor.common.SessionResult;
import net.piggy.core.model.HttpStatement;
import net.piggy.core.session.GatewaySession;

public class DubboGatewaySession implements GatewaySession {
    private final Executor executor;

    public DubboGatewaySession(Executor executor) {
        this.executor = executor;
    }

    @Override
    public SessionResult get(HttpStatement httpStatement, JSONObject params) {
        try {
            return executor.execute(httpStatement, params);
        } catch (Exception e) {
            e.printStackTrace();
            return SessionResult.buildError(null);
        }
    }

}
